<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>版型配置</title>
</head>
<body>
  <h2>版型配置</h2>
  <a href="{{ url_for('index') }}">← 返回主配置</a>

  <form method="post" action="{{ url_for('layout') }}">
    <div>
      <label>新增版型名称: </label>
      <input type="text" name="new_layout_name" placeholder="请输入版型名称">
      <button type="submit" name="action" value="add_layout">新增版型</button>
    </div>

    {% for layout, keywords in layouts.items() %}
    <hr>
    <h3>{{ layout }} <button type="submit" name="delete_layout" value="{{ layout }}">删除此版型</button></h3>
    <div>
      {% for key, value in keywords.items() %}
        <div>
          名称: <input type="text" name="keyword_name_{{ layout }}" value="{{ key }}">
          内容: <input type="text" name="keyword_value_{{ layout }}" value="{{ value }}">
          <button type="submit" name="delete_keyword_{{ layout }}" value="{{ key }}">删除关键字</button>
        </div>
      {% endfor %}
      <div>
        新关键字 - 名称: <input type="text" name="new_keyword_name_{{ layout }}">
        内容: <input type="text" name="new_keyword_value_{{ layout }}">
      </div>
      <button type="submit" name="save_keywords" value="{{ layout }}">保存关键字</button>
    </div>
    {% endfor %}
  </form>
</body>
</html>
